package com.aaa.controller;


import com.aaa.pojo.Student;
import com.aaa.service.IStudentService;
import com.aaa.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * restful风格  path
 * 查询  get
 * 增加  post
 * 修改  put
 * 删除  delete
 */
@RestController
public class StudentController {



    @Autowired
    private IStudentService studentService;

    @GetMapping("/getAll")
    public Result getAll(){
        return studentService.findAll();
    }

   @GetMapping("/getById/{sid}")
    public Result getById(@PathVariable Integer sid){

        return studentService.findById(sid);
    }

    @PostMapping("insert")
    public Result insert(@RequestBody Student student){
        return studentService.insert(student);

    }

    @DeleteMapping("delete/{sid}")
    public Result delete(@PathVariable Integer sid){
        return studentService.delete(sid);
    }

    @PutMapping("update")
    public Result update(@RequestBody Student student){
        return studentService.update(student);
    }
}
